package com.designmodel.designmodel.Iterator_Pattern_迭代器模式;

import java.security.PublicKey;

public class ArrayList  implements  List {
	Object[]  obejcts=new Object[10];
	int index=0;
	@Override
	public void add(Object o) {
		if(obejcts.length==index){
			Object[]  newObj=new Object[10];
			System.arraycopy(obejcts,0,newObj,0,obejcts.length);
			obejcts=newObj;
		}
		obejcts[index]=o;
		index++;
	}

	public int size(){
		return index;
	}

	public Iterator  iterator(){
		return new ArrayListIterator();
	}
	class  ArrayListIterator implements Iterator{
		int currentindex;

		@Override
		public Object next() {
			Object o=new Object();
			o=obejcts[currentindex];
			currentindex++;
			return o;

		}

		@Override
		public boolean hasNext() {
			if(currentindex>=index){
				return false;
			}

			return true;
		}
	}
}
